<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/1/18 0018
  Time: 20:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <base href="${pageContext.request.contextPath}/">
    <link rel="stylesheet" href="assets/layui/css/layui.css">
    <link rel="stylesheet" href="assets/css/base.css">
    <title>Title</title>

</head>
<body>

<div class="page fx-col">
    <input type="hidden" id="id" value="${grade.id}">
    <label>年级名称：<input type="text" id="name" class="layui-input" value="${grade.name}"></label>
    <button class="layui-btn" id="save-btn">保存</button>
</div>


</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="assets/layui/layui.all.js"></script>
<script>
    $(document).on("click","#save-btn",function (){
        let name = $("#name").val();
        let id = $("#id").val();
        $.ajax({
            url:"grade/save",
            type:"post",
            data:{name,id},
            dataType:"json",
            success(res){
                if(res.success()){
                    layer.msg('保存成功',{icon:6},function (){
                        window.parent.search();

                    });
                }else {
                    layer.msg(res.msg,{icon: 2})
                }
            }

        })
    })




</script>



</html>
